import { defineStore } from "pinia";
import mock from '../../mock'
import {  getMdApi } from '@/api/gift'
import axios from 'axios'
import fs from "fs";
import {parse} from "@vue/compiler-sfc";
// import  readFile  from "fs-extra";
// const file = await  readFile("D:\\project2\\comp-manager\\src\\views\\gift\\compoments\\LkSearch.vue", "utf8");
// const { descriptor, error } = parse(file);

export const giftStore = defineStore('gift', { // gift 为名称
    persist: true,
    state: () => {
        return {
            // 礼品列表
            giftList: mock.giftList,
            // 新增礼品入参对象
            newGiftParams: {
                giftCode: "", // 礼品编码
                name: "", // 礼品名称
                shortName: "", // 礼品简称
                brand: "", // 选择的礼品品牌
                type: "", // 选择的礼品类型
                cost: "", // 成本
                unit: "", // 单位
                entering: "", // 录入人
                basicPicList: [
                    {
                        name: "plant-1.png",
                        status: "success",
                        uid: 1666501239386,
                        url: "https://picsum.photos/200",
                    },
                    {
                        name: "plant-2.png",
                        status: "success",
                        uid: 1666501258491,
                        url: "https://picsum.photos/300",
                    },
                    {
                        name: "plant-3.png",
                        status: "success",
                        uid: 1666501281121,
                        url: "https://picsum.photos/900",
                    },
                ], // 基本信息页图片列表
                detailsPicList:[
                    {
                        name: "plant-1.png",
                        status: "success",
                        uid: 1666501239386,
                        url: "https://picsum.photos/200",
                    },
                    {
                        name: "plant-2.png",
                        status: "success",
                        uid: 1666501258491,
                        url: "https://picsum.photos/300",
                    },
                    {
                        name: "plant-3.png",
                        status: "success",
                        uid: 1666501281121,
                        url: "https://picsum.photos/900",
                    },
                ], // 礼品详情页图片列表
                afterPicList:[
                    {
                        name: "plant-1.png",
                        status: "success",
                        uid: 1666501239386,
                        url: "https://picsum.photos/200",
                    },
                    {
                        name: "plant-2.png",
                        status: "success",
                        uid: 1666501258491,
                        url: "https://picsum.photos/300",
                    },
                    {
                        name: "plant-3.png",
                        status: "success",
                        uid: 1666501281121,
                        url: "https://picsum.photos/900",
                    },
                ], // 售后服务页图片列表
                certFileList: [
                    {
                        name: "导入文件名称XXXXXX.xlsx",
                        time: "2016-05-03 10:66:66",
                        status: "success",
                        uid: 1666501239386,
                        url: "https://picsum.photos/200",
                    },
                    {
                        name: "导入文件名称XXXXXX.ppt",
                        time: "2016-05-03 10:66:66",
                        status: "success",
                        uid: 1666501258491,
                        url: "https://picsum.photos/300",
                    },
                    {
                        name: "导入文件名称XXXXXX.doc",
                        time: "2016-05-03 10:66:66",
                        status: "success",
                        uid: 1666501281121,
                        url: "https://picsum.photos/400",
                    },
                ], // 礼品资质文件列表
                checkList: [
                    {
                        node: "初审", // 审批节点
                        result: "通过", // 审批结果
                        remark: "内容太少太少太少", // 备注
                        checkName: "宇智波鼬", // 审批人
                        checkTime: "2022-09-25 16:00:00", // 审批时间
                    },
                    {
                        node: "复审", // 审批节点
                        result: "不通过", // 审批结果
                        remark: "内容太少太少太少", // 备注
                        checkName: "波风水门", // 审批人
                        checkTime: "2022-09-25 16:00:00", // 审批时间
                    },
                    {
                        node: "初审", // 审批节点
                        result: "通过", // 审批结果
                        remark: "内容太少太少太少", // 备注
                        checkName: "自来也", // 审批人
                        checkTime: "2022-09-25 16:00:00", // 审批时间
                    },
                ], // 审批列表
            },
            // 礼品品牌 和 礼品类目
            brandAndType: {
                brandList: [ // 礼品品牌
                    {
                        label: "华为",
                        value: "01",
                    },
                    {
                        label: "苹果",
                        value: "02",
                    },
                    {
                        label: "小米",
                        value: "03",
                    },
                ],
                typeList: [ // 礼品类目
                    {
                        value: "guide",
                        label: "Guide",
                        children: [
                            {
                                value: "disciplines",
                                label: "Disciplines",
                                children: [
                                    {
                                        value: "consistency",
                                        label: "Consistency",
                                    },
                                    {
                                        value: "feedback",
                                        label: "Feedback",
                                    },
                                    {
                                        value: "efficiency",
                                        label: "Efficiency",
                                    },
                                    {
                                        value: "controllability",
                                        label: "Controllability",
                                    },
                                ],
                            },
                            {
                                value: "navigation",
                                label: "Navigation",
                                children: [
                                    {
                                        value: "side nav",
                                        label: "Side Navigation",
                                    },
                                    {
                                        value: "top nav",
                                        label: "Top Navigation",
                                    },
                                ],
                            },
                        ],
                    },
                ]
            },

            checkList: ['选中且禁用','复选框 A'],

            vueCode:''

        }
    },
    getters: {
        // 礼品品牌
        brandList() {
            return this.brandAndType.brandList
        },
        // 礼品类目
        typeList() {
            return this.brandAndType.typeList
        }
    },
    actions: {
        // 获取礼品列表
        getGiftList(params) {
            // 请求礼品列表接口
            console.log(params);
        },
        // 获取 礼品品牌 和 礼品类目
        getBrandAndType(params) {
            console.log('调用礼品品牌礼品类目接口');
        },
        // 汇总新增礼品入参对象
        getNewGiftParams(params){
            console.log('新增礼品入参对象',params);
        },

        getVue(){
            axios({
                method: 'get',
                url: 'http://localhost:9099/dist/vueCode/LkSearch/LkSearch.txt',
            }).then(res =>{
                console.log(res.data)
                this.vueCode = res.data
            }).catch(err=>{
                console.log(err)
            })
        }

    }
})
